<?php
require_once 'class.Page.php';

class Index extends Page
{
    protected function _parse_parameters ()
    {
        $this->page = substr($this->uri, 1);
		$this->tpl = G::tpl();
    }

    protected function _index ()
    {
		$dir = _TPL . 'index' . _DS;
		if ($this->page=='') {
			if (_CHANNEL=='www') {
				return $this->_site_index($dir.'index.html');
			} else {
				if (file_exists($dir.'index_'._CHANNEL.'.html')) {
					return $this->_channel_index($dir.'index_'._CHANNEL.'.html');
				} else {
					return $this->_channel_index($dir.'index_channel_default.html');
				}
			}
		}
        if ($this->page=='privacy.html') return $this->tpl->display($dir.'privacy.html');
        if ($this->page=='contact_us.html') return $this->tpl->display($dir.'contact_us.html');
		G::p404('Sorry, page "<i>'.$this->page.'</i>" not found.');
	}

	protected function _site_index ($tplfile)
	{
		$this->tpl->display($tplfile);
	}

	protected function _channel_index ($tplfile)
	{
		$this->tpl->display($tplfile);
	}
}